package com.sky.controller.User;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("usercategorycontroller")
@Slf4j
@RequestMapping("//user/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;
    /**
     * 用户端根据类型查询分类
     * @return
     */
    @GetMapping("/list")
    public Result<List<Category>> getList(Integer type){
        log.info("用户端根据类型查询分类,传过来的类型为:{}",type);
        List<Category> categoryList = categoryService.list(type);
        return Result.success(categoryList);
    }
}
